<?php

namespace App\Http\Controllers\Api\V1;

use App\Http\Requests\RoundStaticProfitRequest;
use App\Models\RoundStaticProfitSetup;
use App\Transformers\RoundStaticProfitTransformer;
use Dingo\Api\Exception\ResourceException;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class RoundStaticProfitController extends Controller
{
    public function index(RoundStaticProfitRequest $request)
    {
        $amount = $request->amount;
        $res = RoundStaticProfitSetup::where('min_amount','<=',(int)$amount)->where('max_amount','>=',(int)$amount)->first();
        if (!$res) {
            throw new ResourceException('error',[['error_code'=>'500002','message'=>'没有收益率，不可下单！']]);
        }
        return $this->response->item($res,new RoundStaticProfitTransformer());

    }
}
